package c.c.b.a.a;

import java.util.Arrays;

/* compiled from: SegmentedByteString */
public final class u extends h {
    public final transient byte[][] f;
    public final transient int[] g;

    public u(e eVar, int i) {
        int i2;
        super(null);
        y.a(eVar.b, 0, (long) i);
        s sVar = eVar.a;
        int i3 = 0;
        int i4 = 0;
        int i5 = 0;
        while (i4 < i) {
            i2 = sVar.c;
            int i6 = sVar.b;
            if (i2 != i6) {
                i4 += i2 - i6;
                i5++;
                sVar = sVar.f;
            } else {
                throw new AssertionError("s.limit == s.pos");
            }
        }
        this.f = new byte[i5][];
        this.g = new int[(i5 * 2)];
        s sVar2 = eVar.a;
        int i7 = 0;
        while (i3 < i) {
            byte[][] bArr = this.f;
            bArr[i7] = sVar2.a;
            i5 = sVar2.c;
            i2 = sVar2.b;
            i5 = (i5 - i2) + i3;
            i3 = i5 > i ? i : i5;
            int[] iArr = this.g;
            iArr[i7] = i3;
            iArr[bArr.length + i7] = i2;
            sVar2.d = true;
            i7++;
            sVar2 = sVar2.f;
        }
    }

    public byte a(int i) {
        int i2;
        y.a((long) this.g[this.f.length - 1], (long) i, 1);
        int x = x(i);
        if (x == 0) {
            i2 = 0;
        } else {
            i2 = this.g[x - 1];
        }
        int[] iArr = this.g;
        byte[][] bArr = this.f;
        return bArr[x][(i - i2) + iArr[bArr.length + x]];
    }

    public h c(int i, int i2) {
        return y().c(i, i2);
    }

    /* JADX WARNING: Missing block: B:8:0x001d, code skipped:
            if (l(0, r5, 0, v()) != false) goto L_0x0021;
     */
    public boolean equals(java.lang.Object r5) {
        /*
        r4 = this;
        r0 = 1;
        if (r5 != r4) goto L_0x0004;
    L_0x0003:
        return r0;
    L_0x0004:
        r1 = r5 instanceof c.c.b.a.a.h;
        r2 = 0;
        if (r1 == 0) goto L_0x0020;
    L_0x0009:
        r5 = (c.c.b.a.a.h) r5;
        r1 = r5.v();
        r3 = r4.v();
        if (r1 != r3) goto L_0x0020;
    L_0x0015:
        r1 = r4.v();
        r5 = r4.l(r2, r5, r2, r1);
        if (r5 == 0) goto L_0x0020;
    L_0x001f:
        goto L_0x0021;
    L_0x0020:
        r0 = 0;
    L_0x0021:
        return r0;
        */
        throw new UnsupportedOperationException("Method not decompiled: c.c.b.a.a.u.equals(java.lang.Object):boolean");
    }

    public int hashCode() {
        int i = this.b;
        if (i != 0) {
            return i;
        }
        i = this.f.length;
        int i2 = 0;
        int i3 = 0;
        int i4 = 1;
        while (i2 < i) {
            byte[] bArr = this.f[i2];
            int[] iArr = this.g;
            int i5 = iArr[i + i2];
            int i6 = iArr[i2];
            i3 = (i6 - i3) + i5;
            while (i5 < i3) {
                i4 = (i4 * 31) + bArr[i5];
                i5++;
            }
            i2++;
            i3 = i6;
        }
        this.b = i4;
        return i4;
    }

    public String j() {
        return y().j();
    }

    public void k(e eVar) {
        int length = this.f.length;
        int i = 0;
        int i2 = 0;
        while (i < length) {
            int[] iArr = this.g;
            int i3 = iArr[length + i];
            int i4 = iArr[i];
            s sVar = new s(this.f[i], i3, (i3 + i4) - i2, true, false);
            s sVar2 = eVar.a;
            if (sVar2 == null) {
                sVar.g = sVar;
                sVar.f = sVar;
                eVar.a = sVar;
            } else {
                sVar2.g.b(sVar);
            }
            i++;
            i2 = i4;
        }
        eVar.b += (long) i2;
    }

    public boolean l(int i, h hVar, int i2, int i3) {
        if (i < 0 || i > v() - i3) {
            return false;
        }
        int x = x(i);
        while (i3 > 0) {
            int i4;
            if (x == 0) {
                i4 = 0;
            } else {
                i4 = this.g[x - 1];
            }
            int min = Math.min(i3, ((this.g[x] - i4) + i4) - i);
            int[] iArr = this.g;
            byte[][] bArr = this.f;
            if (!hVar.m(i2, bArr[x], (i - i4) + iArr[bArr.length + x], min)) {
                return false;
            }
            i += min;
            i2 += min;
            i3 -= min;
            x++;
        }
        return true;
    }

    public boolean m(int i, byte[] bArr, int i2, int i3) {
        if (i < 0 || i > v() - i3 || i2 < 0 || i2 > bArr.length - i3) {
            return false;
        }
        int x = x(i);
        while (i3 > 0) {
            int i4;
            if (x == 0) {
                i4 = 0;
            } else {
                i4 = this.g[x - 1];
            }
            int min = Math.min(i3, ((this.g[x] - i4) + i4) - i);
            int[] iArr = this.g;
            byte[][] bArr2 = this.f;
            if (!y.b(bArr2[x], (i - i4) + iArr[bArr2.length + x], bArr, i2, min)) {
                return false;
            }
            i += min;
            i2 += min;
            i3 -= min;
            x++;
        }
        return true;
    }

    public String o() {
        return y().o();
    }

    public String t() {
        return y().t();
    }

    public String toString() {
        return y().toString();
    }

    public h u() {
        return y().u();
    }

    public int v() {
        return this.g[this.f.length - 1];
    }

    public byte[] w() {
        int[] iArr = this.g;
        byte[][] bArr = this.f;
        byte[] bArr2 = new byte[iArr[bArr.length - 1]];
        int length = bArr.length;
        int i = 0;
        int i2 = 0;
        while (i < length) {
            int[] iArr2 = this.g;
            int i3 = iArr2[length + i];
            int i4 = iArr2[i];
            System.arraycopy(this.f[i], i3, bArr2, i2, i4 - i2);
            i++;
            i2 = i4;
        }
        return bArr2;
    }

    public final int x(int i) {
        i = Arrays.binarySearch(this.g, 0, this.f.length, i + 1);
        return i >= 0 ? i : ~i;
    }

    public final h y() {
        return new h(w());
    }
}
